<template>
  <el-dialog v-model="dialogVisible" custom-class="dialog">
    <div class="container">
      <div class="header">
        <el-divider>请选择注册身份</el-divider>
      </div>
      <div class="tBtn">
        <div class="item">
          <div class="img">
            <img src="../../assets/image/personal.png" alt="" />
          </div>
          <el-radio
            v-model="radio"
            label="personal"
            @change="radioChange(radio)"
            ><span>个人</span></el-radio
          >
        </div>
        <div class="item">
          <div class="img">
            <img src="../../assets/image/agency.png" alt="" />
          </div>
          <el-radio v-model="radio" label="agency" @change="radioChange(radio)"
            ><span>旅行社</span></el-radio
          >
        </div>
      </div>
      <div class="next">
        <button @click="nextStep()">下一步</button>
      </div>
    </div>
  </el-dialog>
</template>

<script>
import { ElMessage } from "element-plus";
import { reactive, ref } from "vue";
import { type } from "windicss/utils";
import router from "../../router";
export default {
  name: "registerDialog",
  props: {
    dialogVisible: {
      type: Boolean,
      default: false,
    },
  },
  setup(props, { emit }) {
    const radioStatus = ref('');
    const radio = ref('');
    // 个人注册路由
    let personalRegister = reactive({str: "注册",path: "/loginRegister/register"});
    let agencyRegister = reactive({str: "旅行社注册",path: "/loginRegister/agencyRegister"});
    // radio改变触发
    const radioChange = (type) => {
      radioStatus.value = type;
      // console.log("radioChange-->", type);
    };
    // 下一步
    const nextStep = ()=>{
      if(radioStatus.value){
        // console.log('下一步去哪？--->',radioStatus.value);
        // 去个人注册
        if(radioStatus.value === "personal"){
          router.push({
            path:personalRegister.path,
            str:personalRegister.str
          })
        }
        // 去旅行社注册
        else{
          router.push({
            path:agencyRegister.path,
            str:agencyRegister.str
          })
        }
      }else{
        ElMessage({
          message:"请先选择注册身份!",
          type:'warning'
        })
      }
    }
    return {
      radio,
      radioChange,
      nextStep
    };
  },
};
</script>
<style lang="less">
.el-overlay {
  background-color: rgb(0 0 0 / 30%) !important;
}
.dialog {
  width: 680px !important;
  height: 490px;
  background: #ffffff;
  box-shadow: 0px 0px 34px 1px rgba(220, 233, 252, 0.52) !important;
  border-radius: 4px !important;
  margin-top: 314px !important;
  .el-dialog__header {
    display: none;
  }
  .container {
    height: 400px;
    width: 640px;
    // background-color: skyblue;
    text-align: center;
    margin-top: 20px;
    .next {
      width: 140px;
      height: 60px;
      line-height: 60px;
      margin: auto;
      margin-top: 120px;
      button {
        width: 100%;
        height: 100%;
        background: #1277fe;
        border-radius: 4px;
        font-size: 20px;
        font-family: Source Han Sans CN;
        font-weight: 400;
        color: #ffffff;
      }
    }
    .header {
      width: 60%;
      margin: auto;
      .el-divider {
        .el-divider__text {
          font-size: 18px;
          font-family: PingFang SC;
          font-weight: 500;
          color: #999999;
        }
      }
    }
    .tBtn {
      display: flex;
      justify-content: space-evenly;
      margin-top: 90px;
      .item {
        height: 100px;
        width: 100px;
        .el-radio {
          span {
            display: inline-block;
            width: 60px;
            text-align: center;
          }
          .is-checked {
            .el-radio__inner {
              border-color: #f9b047;
              background-image: url("../../assets/image/isChecked.png");
              background-size: 25px 25px;
              background-position: center;
              display: inline-block;
            }
          }
          .el-radio__input {
            position: absolute;
            left: 60px;
            top: -20px;
            height: 20px !important;
            width: 20px !important;
            .el-radio__inner {
              height: 100%;
              width: 100%;
            }
          }
          .el-radio__inner::after {
            content: "";
            display: none;
          }
          .el-radio__inner:hover {
            border-color: #f9b047 !important;
          }
          .el-radio__label {
            width: 60px;
            font-size: 18px;
            font-family: PingFang SC;
            font-weight: 500;
            color: #666666;
            margin-top: 20px;
            padding-left: 0;
          }
        }
      }
    }
  }
}
</style>
